# Maintainer: Alexey Pavlov <alexpux@gmail.com>

pkgbase=gpgme
pkgname=('libgpgme' 'libgpgme-devel')
pkgver=1.6.0
pkgrel=1
pkgdesc="A C wrapper library for GnuPG"
arch=('i686' 'x86_64')
url="http://www.gnupg.org/related_software/gpgme/"
license=('LGPL')
depends=('libassuan' 'libgpg-error' 'gnupg')
makedepends=('libassuan-devel' 'libgpg-error-devel')
options=('!libtool' '!emptydirs')
source=(ftp://ftp.gnupg.org/gcrypt/${pkgbase}/${pkgbase}-${pkgver}.tar.bz2{,.sig}
        gpgme-1.4.2-msys2.patch)
sha1sums=('21510323495f6220f8f67610c3c27a23d761d43d'
          'SKIP'
          '562bb9e2384eff04c4a62a2cf9bd18f9cbf22d74')

prepare() {
  cd ${srcdir}/${pkgbase}-${pkgver}
  patch -p1 -i ${srcdir}/gpgme-1.4.2-msys2.patch

  autoreconf -ivf
}

build() {
  cd ${srcdir}/${pkgbase}-${pkgver}
  ./configure \
    --prefix=/usr \
    --sysconfdir=/etc \
    --localstatedir=/var \
    --build=${CHOST} \
    --disable-gpgsm-test \
    --disable-gpgconf-test \
    --disable-g13-test \
    --enable-shared \
    --enable-static \
    --enable-fixed-path="/usr/bin:/bin:/usr/sbin:/usr/local/bin"

  make no_undefined=-no-undefined
  make DESTDIR=${srcdir}/dest install
}

check() {
  cd ${srcdir}/${pkgbase}-${pkgver}
  #make check
}

package_libgpgme() {
  groups=('libraries')
  install=${pkgname}.install

  mkdir -p ${pkgdir}/usr/{bin,share}
  cp -f ${srcdir}/dest/usr/bin/*.dll ${pkgdir}/usr/bin/
  #cp -rf ${srcdir}/dest/usr/share/doc ${pkgdir}/usr/share/
  cp -rf ${srcdir}/dest/usr/share/info ${pkgdir}/usr/share/
}

package_libgpgme-devel() {
  pkgdesc="Libgpgme headers and libraries"
  groups=('development')
  depends=("libgpgme=${pkgver}" 'libassuan-devel' 'libgpg-error-devel')
  options=('staticlibs')

  mkdir -p ${pkgdir}/usr/{bin,share}
  cp -f ${srcdir}/dest/usr/bin/*-config ${pkgdir}/usr/bin/
  cp -rf ${srcdir}/dest/usr/include ${pkgdir}/usr/
  cp -rf ${srcdir}/dest/usr/lib ${pkgdir}/usr/
  cp -rf ${srcdir}/dest/usr/share/aclocal ${pkgdir}/usr/share/
  cp -rf ${srcdir}/dest/usr/share/common-lisp ${pkgdir}/usr/share/
}
